<script>
$(document).ready(function() {
	<?php
	if ($permissed == 1) echo 'showNoti("Nhóm: '.$name.'", "Phân quyền thành công!", "Ok");';
	if ($failed == 1) echo 'showNoti("Nhóm: '.$name.'", "Phân quyền thất bại!", "Err");';
	?>
});
</script>
<?php
echo form_open($action, array('id' => 'updateFrm'));
echo form_input(array('type' => 'hidden', 'name' => 'token', 'value' => $GLOBALS['var']['token']));
echo form_input(array('type' => 'hidden', 'name' => 'id', 'value' => $group['id']));
echo form_input(array('type' => 'hidden', 'name' => 'name_vn', 'value' => $group['name_vn']));
echo module_open();
$grouprights = json_decode($group['group_rights']);
foreach ($all_rights as $key => $groups)
{
	echo '<tr><td class="head" style="text-transform: uppercase;">'.$GLOBALS['modules_groups'][$key]['name'].'</td></tr>';
	echo '<tr><td>';
	foreach ($groups as $right)
	{
		$act = json_decode($right['rights']);
	?>
		<div class="div_admincats fr" style="border: none; margin: 5px 5px; width: 130px; height: 110px !important;">
			<img src="img/modules/<?php echo $right['image'] ?>" style="width: 36px !important; height: auto;" /><br /><span class="name" style="min-height: 32px"><?php echo $right['name_vn'] ?></span>
			<div class="rights">
				<?php
				$check = 0;
				if ($act->view)
				{
					if (@array_key_exists($right['file'], $grouprights)) $check = $grouprights->$right['file']->view;
					echo '<div>';
					echo '<i class="icon glyphicons '.($check == 1 ? 'red' : 'gray').' list" title="Xem"></i>';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][view]" data-type="1" type="checkbox" value="1"'.($check == 1 ? ' checked="checked"' : '').' />';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][view]" data-type="0" type="checkbox" value="0"'.($check == 0 ? ' checked="checked"' : '').' />';
					echo '</div>';
				}
				if ($act->add)
				{
					if (@array_key_exists($right['file'], $grouprights)) $check = $grouprights->$right['file']->add;
					echo '<div>';
					echo '<i class="icon glyphicons '.($check == 1 ? 'red' : 'gray').' circle_plus" title="Thêm mới"></i>';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][add]" data-type="1" type="checkbox" value="1"'.($check == 1 ? ' checked="checked"' : '').' />';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][add]" data-type="0" type="checkbox" value="0"'.($check == 0 ? ' checked="checked"' : '').' />';
					echo '</div>';
				}
				if ($act->edit)
				{
					if (@array_key_exists($right['file'], $grouprights)) $check = $grouprights->$right['file']->edit;
					echo '<div>';
					echo '<i class="icon glyphicons '.($check == 1 ? 'red' : 'gray').' edit" title="Chỉnh sửa"></i>';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][edit]" data-type="1" type="checkbox" value="1"'.($check == 1 ? ' checked="checked"' : '').' />';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][edit]" data-type="0" type="checkbox" value="0"'.($check == 0 ? ' checked="checked"' : '').' />';
					echo '</div>';
				}
				if ($act->del)
				{
					if (@array_key_exists($right['file'], $grouprights)) $check = $grouprights->$right['file']->del;
					echo '<div>';
					echo '<i class="icon glyphicons '.($check == 1 ? 'red' : 'gray').' bin" title="Xóa / Khôi phục"></i>';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][del]" data-type="1" type="checkbox" value="1"'.($check == 1 ? ' checked="checked"' : '').' />';
					echo '<input data-no-uniform="true" name="rights['.$right['file'].'][del]" data-type="0" type="checkbox" value="0"'.($check == 0 ? ' checked="checked"' : '').' />';
					echo '</div>';
				}
				?>
			</div>
		</div>
	<?php
	}
	echo '</td></tr>';
}
echo module_close();
echo form_close();
?>